package priv.utrix.micro.compont;

import cn.hutool.core.date.DateUtil;
import cn.hutool.core.date.TimeInterval;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;
import priv.utrix.micro.utils.RedisUtil;

/**
 * 应用启动后执行
 *
 * @author utrix
 * @date 2020/12/5
 */
@Slf4j
@Component
@RequiredArgsConstructor
public class AfterApplicationRunner implements ApplicationRunner {

    final RedisUtil redisUtil;

    @Override
    public void run(ApplicationArguments args) throws Exception {
        log.info("The certification authority clears the Redis cache and starts ......");
        TimeInterval timer = DateUtil.timer();
        redisUtil.clear();
        long millisecond = timer.intervalMs();
        log.info("The redis cache is emptied, time consuming {} ms .....O(∩_∩)O", millisecond);
    }
}
